<template>
  <div class="yh_content">
    <div class="yh_topsearch yh_dis yh_disJub" style="border: none; padding: 0px;">
      <div class="dis">
        <div class="mar-right10">
          <div class="foSi12" style="height: 20px;color: #787878;">发送时间</div>
          <div class="dis disAl hei40">
            <el-date-picker
              v-model="search.start"
              style="width: 140px;"
              type="date"
              placeholder="开始时间"
              :picker-options="{disabledDate:dateOptions}"
            />
            <el-date-picker
              v-model="search.end"
              class="mar-left10"
              style="width: 140px;"
              type="date"
              :picker-options="{disabledDate:dateOptions}"
              placeholder="截止时间"
            />
          </div>
        </div>
        <!--        <div class="mar-right10">-->
        <!--          <div class="foSi12" style="height: 20px;color: #787878;">发送类型</div>-->
        <!--          <div class="dis disAl hei40">-->
        <!--            <el-select v-model="search.message_id" style="width: 200px">-->
        <!--              <el-option-->
        <!--                v-for="(item,index) in search.stateList"-->
        <!--                :key="index"-->
        <!--                :label="item.label"-->
        <!--                :value="item.value"-->
        <!--              />-->
        <!--            </el-select>-->
        <!--          </div>-->
        <!--        </div>-->
        <div class="hei60 dis disAl" style="padding-top: 20px;">
          <el-button type="primary" style="height: 32px;" @click.stop="suosou">搜索</el-button>
        </div>
      </div>
    </div>
    <div style="margin-top: 20px">
      <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
        <div slot="empty" class="m-empty-box">
          <div class="mar" style="width: 168px;height: 180px;">
            <img src="https://www.jianyigongxiang.com/public/membercard/empty.png" class="wh100">
          </div>
          <div class="title">暂无数据</div>
        </div>
        <el-table-column prop="nickname" label="会员" />
        <el-table-column prop="mobile" label="手机号" />
        <el-table-column prop="title" label="发送类型" />
        <el-table-column prop="nums" label="条数" />
        <el-table-column prop="createtime" label="发送时间" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import {
  getXuan,
  judgeButton
} from '@/utils/limits.js'
import {
  mapGetters
} from 'vuex'
import { YzmSendRecord, TitleList } from '@/api/sms'
export default {
  name: 'SmsSendRecord',
  components: {
    Pagination
  },
  data() {
    return {
      list: null,
      total: 0,
      listLoading: false,
      search: {
        stateList: [], // 状态
        start: '',
        end: '',
        message_id: ''
      },
      listQuery: {
        page: 1,
        limit: 10
      },
      // 选择今天及今天以后的日期
      dateOptions(time) {
        return time.getTime() >= Date.now() - 8.64e6
      }
    }
  },
  computed: {
    ...mapGetters([
      'permission_routes',
      'roles'
    ])
  },
  created() {
    var xuanList = [{
      name: '短信发送记录',
      url: '/sms/smsSendRecord',
      pd: true
    }]
    var xuanList1 = getXuan(xuanList, this.roles)
    this.$store.dispatch('user/changeXuan', {
      key: 'xuanList',
      value: xuanList1
    })
    this.$store.dispatch('user/changeXuan', {
      key: 'xuan',
      value: 0
    })
    this.getList()
    this.gettitleList()
  },
  methods: {
    gettitleList() {
      var data = {}
      TitleList(data).then(response => {
        const {
          data
        } = response
        this.search.stateList = data
        this.listLoading = false
      }).catch(error => {
        console.log(error)
        this.listLoading = false
      })
    },
    suosou() {
      this.listQuery = {
        page: 1,
        limit: 10
      }
      this.getList()
    },
    getList() {
      this.listLoading = true
      var data = {
        page: this.listQuery.page,
        limit: this.listQuery.limit,
        start_time: this.search.start,
        end_time: this.search.end,
        message_id: this.search.message_id
      }
      YzmSendRecord(data).then(response => {
        const {
          data
        } = response
        this.list = data.data
        this.total = data.total
        this.listLoading = false
      }).catch(error => {
        console.log(error)
        this.listLoading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
	.yh_content {
		padding: 20px;
	}

	.yh_topsearch {
		border: 1px solid #ccc;
		padding: 20px 20px 0px 20px;
	}

	.yh_dis {
		display: flex;
	}

	.yh_disAlc {
		align-items: center;
	}

	.topsearch_item {
		/* padding: 20px; */
	}

	.search_left {
		width: 150px;
		font-size: 12px;
		color: #838383;
	}

	.search_right {
		flex-wrap: wrap;
	}

	.sons {
		margin-left: 20px;
		cursor: pointer;
		font-size: 12px;
		margin-bottom: 15px;
	}

	.choiceme {
		color: rgb(32, 146, 48);
		font-size: 12px;
	}

	.yh_xian {
		border-bottom: 1px solid #e7e7e7;
		/* width: 98%; */
		margin: 0px auto;
		margin-bottom: 20px;
	}

	.yh_qs {
		color: #838383;
	}

	.yh_disJub {
		justify-content: space-between;
	}

	.yh_disJuc {
		justify-content: center;
	}

	.yh_font12 {
		font-size: 12px;
	}

	.yh_font13 {
		font-size: 13px;
	}

	::v-deep .el-input__inner {
		height: 32px;
		line-height: 32px;
	}
</style>
